package com.woniuxy.auth.controller;/*
@author houguai
@create 2021-03-03 16:40
*/

import com.woniuxy.auth.entity.Rbac_perm;
import com.woniuxy.auth.jwt.Audience;
import com.woniuxy.auth.jwt.JwtUtil;
import com.woniuxy.auth.service.Rbac_permService;
import com.woniuxy.ticketcommon.ResponceResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("menu")
public class MenuController {

    @Autowired
    private Audience audience;

    @Autowired
    private Rbac_permService permService;


    @RequestMapping("get")
    public ResponceResult<List<Rbac_perm>> getMenus(@RequestHeader("jwt")String jwt){

        int id= JwtUtil.getUserId(jwt,audience.getBase64Secret());

        return new ResponceResult<>(permService.getPermById(id));
    }

    @RequestMapping("add")
    public ResponceResult<Void> addMenu(){

        return ResponceResult.SUCCESS;
    }
}
